package com.yingma.common.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author ysf
 * @date 2020/3/13 18:16
 */
@Configuration
@EnableSwagger2      //开启Swagger2
public class SwaggerConfig {

    //配置了Swagger的Docket的bean实例

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(createApiInfo())
                .groupName("ysf")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.yingma.common.controller"))
                //过滤
//                .paths(PathSelectors.any())
                .build();
    }
    //配置了Swagger的信息=apiInfo
    @Bean
    public ApiInfo createApiInfo() {
        return new ApiInfoBuilder()
                .title("ysf的测试使用Swagger")
                .termsOfServiceUrl("http://localhost:8080/test_shiro")
                .version("1.0.0")
                .description("练习使用swagger").build();
    }


}
